package com.kly.order.db.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.google.common.collect.Maps;
import com.kly.enums.ProductStatus;
import com.kly.order.db.dao.ConsumptionRecordDao;
import com.kly.order.db.dbo.UserPCountDBO;
import com.kly.order.db.entity.ConsumptionRecordEntity;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Map;

/**
* User: 11437
* Date: 2023-08-02
* Time: 17:29:37.922
*/

@Repository
public class ConsumptionRecordDaoImpl extends AbstractBaseMapper<ConsumptionRecordEntity> implements ConsumptionRecordDao {

    @Override
    public ConsumptionRecordEntity getLastRecord(String userCode, String chatUserCode, String imageCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("chatUserCode", chatUserCode);
        params.put("imageCode", imageCode);
        return this.getSqlSession().selectOne(this.getStatement("getLastRecord"), params);
    }


    @Override
    public List<UserPCountDBO> getUserPCount(String chatUserCode, String chatterUserCode, LocalDateTime startTime, LocalDateTime endTime) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("chatUserCode", chatUserCode);
        params.put("chatterUserCode", chatterUserCode);
        params.put("startTime", startTime);
        params.put("endTime", endTime);
        return this.getSqlSession().selectList(this.getStatement("getUserPCount"), params);
    }

    @Override
    public int getUnlockCount(String userCode, String chatUserCode, String imageCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("chatUserCode", chatUserCode);
        params.put("imageCode", imageCode);
        return (Integer) this.getSqlSession().selectOne(this.getStatement("getUnlockCount"), params);
    }

    @Override
    public List<ConsumptionRecordEntity> unLockList(String chatUserCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("chatUserCode", chatUserCode);
        return this.getSqlSession().selectList(this.getStatement("unLockList"), params);
    }

    @Override
    public List<ConsumptionRecordEntity> listBenefits(String userCode, String chatUserCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("chatUserCode", chatUserCode);
        return this.getSqlSession().selectList(this.getStatement("listBenefits"), params);
    }


    @Override
    public List<UserPCountDBO> listUnlockNum(String chatterUserCode, String startDate, String endDate) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("chatterUserCode", chatterUserCode);
        params.put("startDate", startDate);
        params.put("endDate", endDate);
        return this.getSqlSession().selectList(this.getStatement("listUnlockNum"), params);
    }
    
}